package cn.iocoder.yudao.module.famous.doctor.dal.mysql.researchgroupuser;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.researchgroupuser.ResearchgroupUserDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.researchgroupuser.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 课题组-用户关联 Mapper
 *
 * @author 启航
 */
@Mapper
public interface ResearchgroupUserMapper extends BaseMapperX<ResearchgroupUserDO> {

    default PageResult<ResearchgroupUserDO> selectPage(ResearchgroupUserPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ResearchgroupUserDO>()
                .eqIfPresent(ResearchgroupUserDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(ResearchgroupUserDO::getUserType, reqVO.getUserType())
                .eqIfPresent(ResearchgroupUserDO::getUserSign, reqVO.getUserSign())
                .betweenIfPresent(ResearchgroupUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResearchgroupUserDO::getId));
    }

    default List<ResearchgroupUserDO> selectList(ResearchgroupUserExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ResearchgroupUserDO>()
                .eqIfPresent(ResearchgroupUserDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(ResearchgroupUserDO::getUserType, reqVO.getUserType())
                .eqIfPresent(ResearchgroupUserDO::getUserSign, reqVO.getUserSign())
                .betweenIfPresent(ResearchgroupUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ResearchgroupUserDO::getId));
    }

    /**
     * 根据身份证 查询该患者是否是临床患者
     * @param userType
     * @param identityCard
     * @return
     */
    List<ResearchgroupUserByClinic> selectClinicList(@Param("userType") Long userType, @Param("identityCard") String identityCard);

    IPage<ResearchgroupUserByClinic> selectClinicPage(Page<Object> objectPage, @Param("param") ResearchgroupUserPageReqVO pageVO);
}
